package com.sgb.kjwl.view.widget;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.NewGoodsDetailEntity.SelectArr.SkuCombinationEntity;
import com.sgb.kjwl.view.ui.adapter.self.publish.SelfShoppingDetailAttrAdapter;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;

public class SelfShoppingDetailAttrWindow extends BasePopWindow {
    private RecyclerView paramsList;
    private TextView tv_close;
    private SelfShoppingDetailAttrAdapter selfShoppingDetailAttrAdapter;
    private LinearLayoutManager linearLayoutManager;


    public SelfShoppingDetailAttrWindow(Context context) {
        super(context, DIR_DOWN_UP);
    }

    @Override
    protected int popLayout() {
        return R.layout.pop_goods_attribute;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        paramsList = holder.getPop().findViewById(R.id.params_list);
        tv_close = holder.getPop().findViewById(R.id.tv_close);
        if (selfShoppingDetailAttrAdapter == null) {
            selfShoppingDetailAttrAdapter = new SelfShoppingDetailAttrAdapter(mContext, null);
        }
        linearLayoutManager = new LinearLayoutManager(mContext);
        paramsList.setLayoutManager(linearLayoutManager);
        paramsList.setAdapter(selfShoppingDetailAttrAdapter);
        tv_close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    public void setData(SkuCombinationEntity data) {
        if (data != null && data.getList() != null)
            selfShoppingDetailAttrAdapter.setDatas(data.getList());
    }
}
